package com.hjm.project.ActActivationReturn.ActActivationReturn.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.ActActivationReturn.ActActivationReturn.domain.ActActivationReturn;
import com.hjm.project.ActActivationReturn.ActActivationReturn.service.IActActivationReturnService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 激活返现Controller
 * 
 * @author ActActivationReturn
 * @date 2020-11-29
 */
@Controller
@RequestMapping("/ActActivationReturn/ActActivationReturn")
public class ActActivationReturnController extends BaseController
{
    private String prefix = "ActActivationReturn/ActActivationReturn";

    @Autowired
    private IActActivationReturnService actActivationReturnService;

    @RequiresPermissions("ActActivationReturn:ActActivationReturn:view")
    @GetMapping()
    public String ActActivationReturn()
    {
        return prefix + "/ActActivationReturn";
    }

    /**
     * 查询激活返现列表
     */
    @RequiresPermissions("ActActivationReturn:ActActivationReturn:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ActActivationReturn actActivationReturn)
    {
        startPage();
        List<ActActivationReturn> list = actActivationReturnService.selectActActivationReturnList(actActivationReturn);
        return getDataTable(list);
    }

    /**
     * 导出激活返现列表
     */
    @RequiresPermissions("ActActivationReturn:ActActivationReturn:export")
    @Log(title = "激活返现", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ActActivationReturn actActivationReturn)
    {
        List<ActActivationReturn> list = actActivationReturnService.selectActActivationReturnList(actActivationReturn);
        ExcelUtil<ActActivationReturn> util = new ExcelUtil<ActActivationReturn>(ActActivationReturn.class);
        return util.exportExcel(list, "ActActivationReturn");
    }

    /**
     * 新增激活返现
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存激活返现
     */
    @RequiresPermissions("ActActivationReturn:ActActivationReturn:add")
    @Log(title = "激活返现", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ActActivationReturn actActivationReturn)
    {
        return toAjax(actActivationReturnService.insertActActivationReturn(actActivationReturn));
    }

    /**
     * 修改激活返现
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ActActivationReturn actActivationReturn = actActivationReturnService.selectActActivationReturnById(id);
        mmap.put("actActivationReturn", actActivationReturn);
        return prefix + "/edit";
    }

    /**
     * 修改保存激活返现
     */
    @RequiresPermissions("ActActivationReturn:ActActivationReturn:edit")
    @Log(title = "激活返现", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ActActivationReturn actActivationReturn)
    {
        return toAjax(actActivationReturnService.updateActActivationReturn(actActivationReturn));
    }

    /**
     * 删除激活返现
     */
    @RequiresPermissions("ActActivationReturn:ActActivationReturn:remove")
    @Log(title = "激活返现", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(actActivationReturnService.deleteActActivationReturnByIds(ids));
    }
}
